// import axios from '@/utils/request'
export default {
  StorePurchase: {
    entity: { name: 'Purchase', prefix: () => `store/${localStorage.getItem('storeId')}` },
    list: {
      disabled_actions:['lines'],
      query: {
        '@filter': `entity.getFromStore().getId() == ${localStorage.getItem('storeId')}`,
        '@order': `entity.createdTime|DESC`
      },
      list_filter: {
        // 'store.id': () => {
        //   return axios
        //     .get(`/manage/stores`)
        //     .then(res =>
        //       Object.assign({ __label: '门店' },
        //         ...res.data.map(v => { return { [v.id]: v.name } })))
        // }
        beforeCreatedTime: {
          expression: 'entity.getCreatedTime() >= datetime.get(":value 00:00:00")',
          label: '下单开始时间',
          type: 'date'
        },
        afterCreatedTime: {
          expression: 'entity.getCreatedTime() <= datetime.get(":value 23:59:59")',
          label: '下单结束时间',
          type: 'date'
        },
      },
      list_display: [
        {
          property: 'user',
          label: '发起账号'
        },
        {
          property: 'items',
          label: '采购内容',
          component: {
            props: ['data'],
            data() {
              return {
                purchaseItems: []
              }
            },
            render(h) {
              return <div style='width: 500px'>
                <el-table
                  data={this.data}
                  style='width: 500px'>
                  <el-table-column
                    prop='__metadata.specification.__toString'
                    label='产品'
                    width='250px'>
                  </el-table-column>
                  <el-table-column
                    prop='__metadata.quantity'
                    label='采购数量'>
                  </el-table-column>
                  <el-table-column
                    prop='__metadata.retrieved'
                    label='已入库'>
                  </el-table-column>
                  <el-table-column
                    prop='__metadata.primeCost'
                    label='采购单价'>
                  </el-table-column>
                </el-table>
              </div>
            }
          }
        },
        {
          property: 'toStore',
          label: '发货仓库'
        },
        'createdTime',
        'comment'
      ]
    },
    form: {
      fields: [
        'user',
        'parchaseItems',
        'comment'
      ]
    }
  }
}

